<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Set the signature algorithm for a phar and apply it</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="phardata.setmetadata.html">« PharData::setMetadata</a></li>
      <li style="float: right;"><a href="phardata.setstub.html">PharData::setStub »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.phardata.html">PharData</a></li>
    <li>Set the signature algorithm for a phar and apply it</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="phardata.setsignaturealgorithm" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">PharData::setSignatureAlgorithm</h1>
  <p class="verinfo">(No version information available, might only be in Git)</p><p class="refpurpose"><span class="refname">PharData::setSignatureAlgorithm</span> &mdash; <span class="dc-title">Set the signature algorithm for a phar and apply it</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-phardata.setsignaturealgorithm-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>PharData::setSignatureAlgorithm</strong></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$algo</code></span>, <span class="methodparam"><span class="type">?</span><span class="type"><span class="type">string</span><span class="type"></span></span> <code class="parameter">$privateKey</code><span class="initializer"> = <strong><code>null</code></strong></span></span>): <span class="type"><span class="type void">void</span></span></div>

  <blockquote class="note"><p><strong class="note">注意</strong>: <p class="para">此方法需要
将 <var class="filename">php.ini</var> 中的 <code class="literal">phar.readonly</code> 设为
<code class="literal">0</code> 以适合 <span class="classname"><a href="class.phar.html" class="classname">Phar</a></span>
对象.  否则, 将抛出<span class="classname"><a href="class.pharexception.html" class="classname">PharException</a></span>.</p></p></blockquote>

  <p class="para">
   Set the signature algorithm for a phar and apply it.  The
   signature algorithm must be one of <code class="literal">Phar::MD5</code>,
   <code class="literal">Phar::SHA1</code>, <code class="literal">Phar::SHA256</code>,
   <code class="literal">Phar::SHA512</code>, or <code class="literal">Phar::OPENSSL</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-phardata.setsignaturealgorithm-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">algo</code></dt>

     <dd>

      <p class="para">
       One of <code class="literal">Phar::MD5</code>,
   <code class="literal">Phar::SHA1</code>, <code class="literal">Phar::SHA256</code>,
   <code class="literal">Phar::SHA512</code>, or <code class="literal">Phar::OPENSSL</code>
      </p>
     </dd>

    
   </dl>

  </p>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-phardata.setsignaturealgorithm-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   没有返回值。
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-phardata.setsignaturealgorithm-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   Throws <span class="classname"><a href="class.unexpectedvalueexception.html" class="classname">UnexpectedValueException</a></span> for many errors,
   <span class="classname"><a href="class.badmethodcallexception.html" class="classname">BadMethodCallException</a></span> if called for a zip- or
   a tar-based phar archive, and a <span class="classname"><a href="class.pharexception.html" class="classname">PharException</a></span>
   if any problems occur flushing changes to disk.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-phardata.setsignaturealgorithm-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">privateKey</code> is now nullable.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 seealso" id="refsect1-phardata.setsignaturealgorithm-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="phar.getsupportedsignatures.html" class="function" rel="rdfs-seeAlso">Phar::getSupportedSignatures()</a> - Return array of supported signature types</span></li>
    <li class="member"><span class="function"><a href="phar.getsignature.html" class="function" rel="rdfs-seeAlso">Phar::getSignature()</a> - Return MD5/SHA1/SHA256/SHA512/OpenSSL signature of a Phar archive</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>